<div class="left-nav left-slider">
    <div class="menus">
      <ul>

      </ul>
    </div>
    <div id="side-nav" class="childrenmenu">
      <ul id="nav">
      </ul>
    </div>
  </div>


    <!-- 侧边菜单 -->
<style>
.left-nav{background: #FFF;}
.left-slider{ padding-top: 0px; }
.left-slider .menus{ width: 50px;height: 100%;background: #28333E;float: left; }
.left-slider .childrenmenu{ float: left;width: 150px !important;padding: 0px 15px; box-sizing: border-box; }
.left-slider .menus .nav-item{ width: 50px;height: 40px;padding: 10px 0px;text-align: center;cursor: pointer; float: left; }
.left-slider .menus .nav-item i{ color: #FFF; }
.left-slider .menus .nav-item .doc-icon-name{ color: #FFF; }
.left-slider .menus div.curt{ background: #FFF; }
.left-slider .menus div.curt i{ color: #28333E; }
.left-slider .menus div.curt .doc-icon-name{ color: #28333E; }
.left-slider .childrenmenu .layui-nav-item{ line-height: 40px; text-align: left;position: relative; display: none; }
.left-slider .childrenmenu .layui-nav-item a span{ position: absolute;right: 20px;top: 10px; }
.left-slider .childrenmenu .layui-nav-item dl.nav-item-child{ text-indent: 0.5em; }
.left-slider .childrenmenu .layui-nav-item dl.nav-item-child dd{ height: 40px; }
.left-slider .childrenmenu .layui-nav-item dl dd a{ display: inline-block;  width: 100%;  height: 100%; color: #666 }
.left-slider .childrenmenu .layui-nav-item dl dd a.curt{ color:  #04f9e2}
.left-slider .layui-nav-item > a{ padding: 0px !important; }
.left-slider .layui-nav-item a{ padding-left: 0px !important; }
#side-nav > li > dl > dd { cursor: pointer }
</style>
<script>
$(function(){
  var menus = {$menus|raw};
  var leftHtml = '';
  var secHtml = '';
  for (var i = 0; i < menus.length; i++) {
    leftHtml += '<div class="nav-item" data-group="'+menus[i].id+'"><i class="'+menus[i].icon+'"></i><div class="doc-icon-name">'+menus[i].title+'</div></div>';
    var secMenu = menus[i].child;
    for (var j = 0; j < secMenu.length; j++) {
      secHtml += '<li class="layui-nav-item" data-group="'+secMenu[j].pid+'"><a href="javascript:void(0);"><i class="fa fa-caret-down"></i><cite>'+secMenu[j].title+'</cite></a><dl class="nav-item-child">'

      var thirdMenu = secMenu[j].child;

      for (var k = 0; k < thirdMenu.length; k++) {
        secHtml += '<dd><a onclick="xadmin.add_tab(\''+thirdMenu[k].title+'\',\''+thirdMenu[k].href+'\')"><cite>'+thirdMenu[k].title+'</cite></a></dd>'
      }
      secHtml += '</dl>'
    }
  }
  $('.menus ul').empty().append(leftHtml);
  $('.childrenmenu').empty().append(secHtml);


  $('.menus div.nav-item:first-child').addClass('curt');
  var data_group = $('.menus div.curt').attr('data-group');
  $('.childrenmenu li.layui-nav-item').each(function(){
    var child_group = $(this).attr('data-group');
    if (data_group == child_group) {
      $(this).show();
    }
  })
  $('.menus div.nav-item').click(function(){
    $(this).addClass('curt').siblings().removeClass('curt');
    var data_group = $(this).attr('data-group');
    $('.childrenmenu li.layui-nav-item').hide();
    $('.childrenmenu li.layui-nav-item').each(function(){
      var child_group = $(this).attr('data-group');
      if (data_group == child_group) {
        $(this).show();
      }
    })
  })
  $('.childrenmenu .layui-nav-item a').click(function(){
    if($(this).next('dl.nav-item-child').is(':visible')){
      $(this).next('dl.nav-item-child').slideUp();
      $(this).find("i").removeClass().addClass("fa fa-caret-right");
      
    }else{
      $(this).next('dl.nav-item-child').slideDown();
      $(this).find("i").removeClass().addClass("fa fa-caret-down");
    }
  })
  $('.childrenmenu .layui-nav-item dl dd').click(function(){
    $(this).parents('li').siblings().find('a').removeClass('curt');
    $(this).parent('dl').find('a').removeClass('curt');
    $(this).find('a').addClass('curt')
  })

})

</script>